ig.module( 
	'game.main' 
)
.requires(
	'impact.game',
	'impact.font',
		
	'game.levels.CatchBalloon',
	
	'game.gameTypes.gameBase',	
	'game.gameTypes.gameCatchBalloon',
	'game.BoxOutline.BoxOutline'	
)
.defines(function()
{
MyGame = ig.Game.extend(
{
	
	// Load a font
	font: new ig.Font( 'media/04b03.font.png' ),
	currentGameName: '',
	currentGame: null,
	
	init: function()
	{
		ig.global.paused = false;
		
		// Initialize your game here; bind keys etc.
		ig.input.bind(ig.KEY.UP_ARROW, 'up');
		ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
		ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
		ig.input.bind(ig.KEY.RIGHT_ARROW, 'right');
		
		ig.input.bind(ig.KEY.ENTER, 'enter');
				
		ig.input.bind(ig.KEY.MOUSE1, 'mouse_left')
		ig.input.bind(ig.KEY.MOUSE3, 'mouse_right')
				
		this.currentGameName = 'CatchBalloon';
		
		switch (this.currentGameName)
		{
			case 'CatchBalloon':
			{
			    this.currentGame = new GameCatchBalloon();
			    this.loadLevel(LevelCatchBalloon);
			}
			break;
		}
		
		this.currentGame.setGame(this);
		this.currentGame.postInit();
	},
	
	update: function()
	{
		if (this.firstUpdate == true)
		{
			
		}
		
		if (ig.global.paused == true)
		{
			this.currentGame.pausedUpdate();
			return;
		}
		
		// Update all entities and backgroundMaps
		this.parent();
		
		// Add your own, additional update code here
		this.currentGame.update();
	},
	
	draw: function()
	{
		// Draw all entities and backgroundMaps
		this.parent();
		
		
		// Add your own drawing code here
		var x = ig.system.width/2,
			y = ig.system.height/2;
		
		var now = (new Date()).getTime();
		var delta = now - this.framerateNow;
		this.framerateNow = (new Date()).getTime();
		this.font.draw( Math.floor(1000/(delta)) + 'fps', 2, 2 );

		//this.font.draw( 'Pontuacao: ' + ig.global.numberOfPicks, 300, 300, ig.Font.ALIGN.CENTER );
		
		this.currentGame.draw();
	}
});


// Start the Game with 60fps, a resolution of 320x240, scaled
// up by a factor of 2
ig.main( '#canvas', MyGame, 60, 640, 480, 1 );

});
